package com.zwp.base.binding


class BindingCommand<T>(
    var execute: BindingAction? = null,
    var consumer: BindingConsumer<T>? = null,
    var canExecute0: BindingFunction<Boolean>? = null
) {

    fun execute() {
        if (execute != null && canExecute()) {
            execute!!.call()
        }
    }

    fun execute(params: T) {
        if (consumer != null && canExecute()) {
            consumer!!.call(params)
        }
    }

    fun canExecute(): Boolean = canExecute0?.call() ?: true
}


//interface BindingAction {
//    fun call()
//}

interface BindingConsumer<T> {
    fun call(t: T)
}

interface BindingFunction<T> {
    fun call(): T
}